<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<link rel="stylesheet" href="../css/left-menu-style.css" />
		<link rel="stylesheet" href="../css/bootstrap.css" />
		<script type="text/javascript" src="../js/jquery-3.2.1.js"></script>
		<script type="text/javascript" src="../js/bootstrap.js"></script>
		<script type="text/javascript" src="../js/getPath.js" ></script>
		<style>
			span a:active,
			span a:visited{
				color: white;
			}
			span a:link{
				padding-left: 15px;
				color: white;
				text-decoration: none;
			}
			span a:hover{
				color: red;
				text-decoration: none;
			}
			
			
		</style>
	</head>
	<body>
		<div class="navbar navbar-duomi navbar-static-top" role="navigation">
			<div class="container-fluid">
				<div class="navbar-header" style="height: 80px;">
					<span class="navbar-brand" id="logo">易通1704在线订票系统</span>
				</div>
				<span style="margin-left:740px;line-height: 50px;">
					<a href="#" id="current">
						
					</a>
					<a href="#" id="shop">
						<i class="glyphicon glyphicon-shopping-cart"></i>我的购物车
					</a>
					<a href="#" id="over">
						<i class="glyphicon glyphicon-off"></i>退出
					</a>
				</span>
				<div style="color:white;margin-left:1250px;margin-top: -35px;" id="counter">
					在线人数:0
				</div>
			</div>
		</div>
	</body>
	<script>
		$(function(){
			
			$.ajax({
				type:'post',
				data:({
					'method':'currentUser',
				}),
				url: getPath() + '/user',
				dataType:'json',
				success:function(data){
					$('#current').append('<i class="glyphicon glyphicon-user"></i>'+data.currentUser);
				}
			});
			
			/**
			 *	购物车
			 */
			$('#shop').bind('click',function(){
				top.location.href = getPath() + "/shop/shop.html";
			});
			
			/**
			 *	退出
			 */
			$('#over').bind('click',function(){
				$.ajax({
					type:'post',
					data:({
						'method':'destroy',
					}),
					url: getPath() + '/user',
					dataType:'json',
					success:function(data){
						top.location.href = getPath() + "/login.html";
					}
				});
			});	
		});
		
		function counter(){
			console.log(123);
			$.ajax({
				type:'post',
				data:({
					'method':'counter',
				}),
				url: getPath() + '/user',
				dataType:'json',
				success:function(data){
					$('#counter').text('在线人数:'+data.counter);
				}
			});
		}
		setInterval(counter,1000);
	</script>
</html>